package com.physics.mps.module.fastcae.vo;

import cn.hutool.core.util.IdUtil;
import com.physics.mps.common.exception.BusinessException;
import com.physics.mps.entity.enums.CodeEnum;
import com.physics.mps.entity.vo.StartComputeVo;
import lombok.Data;

import javax.validation.constraints.NotBlank;

/**
 * @author mcsoft
 * @since 2024/2/21
 */
@Data
public class FastcaeMeshData extends StartComputeVo {
    /**
     * 模型文件地址
     */
    @NotBlank(message = "stpPath不能为空")
    private String stpPath;

    /**
     * 网格类型
     */
    @NotBlank(message = "elementType不能为空")
    private String elementType;

    /**
     * 网格阶次
     */
    @NotBlank(message = "elementOrder不能为空")
    private String elementOrder;

    /**
     * 网格划分方法
     */
    @NotBlank(message = "method不能为空")
    private String method;

    /**
     * 尺寸因子
     */
    @NotBlank(message = "sizeFactor不能为空")
    private String sizeFactor;

    /**
     * 最小尺寸
     */
    @NotBlank(message = "minSize不能为空")
    private String minSize;

    /**
     * 最大尺寸
     */
    @NotBlank(message = "maxSize不能为空")
    private String maxSize;

    /**
     * vtk文件目录
     */
    private String meshPath;

    /**
     * 任务id
     */
    //private String subTaskId;

    /**
     * 修正参数 根据网格划分方式生成对应id
     * @param meshPath
     */
    public void modify(String meshPath) {
        //setSubTaskId(IdUtil.simpleUUID());
        //this.meshPath = meshPath + IdUtil.simpleUUID();
        setTaskName(getTaskName() + "-" + IdUtil.simpleUUID());
        this.meshPath = meshPath + getTaskName();
        switch (method) {
            case "Delaunay":
                method = "1";
                break;
            case "New Delaunay":
                method = "2";
                break;
            case "Frontal":
                method = "4";
                break;
            case "Frontal Delaunay":
                method = "5";
                break;
            case "Frontal Hex":
                method = "6";
                break;
            case "MMG3D":
                method = "7";
                break;
            case "R-tree":
                method = "9";
                break;
            default:
                throw new BusinessException(CodeEnum.MESH_METHOD_ERROR);
        }
    }
}
